<?php


namespace app\common\models;


class Product extends BaseModel
{
    public $table = 'yq_product';
    public $timestamps = true;
    protected $guarded = [''];

    public function category()
    {
        return $this->hasOne(Category::class, 'id', 'cid');
    }

    public function channel()
    {
        return $this->hasMany(ProductChannel::class, "product_id",'id');
    }
    public function property()
    {
        return $this->hasMany(ProductProperty::class, "product_id",'id');
    }

    public  function atributeNames() {
        return [
            'cid'  => '分类',
            'name' => '产品名称',
            'price' => '产品现价',
        ];
    }

    public  function rules()
    {
        return [
            'cid'  => 'required',
            'name' => 'required',
            'price' => 'required',
        ];
    }

}
